$(function(){
	// 产品搜索
	var def_val = $("#keyword_search").val();
	$("#keyword_search").focus(function() {
		var this_val = $("#keyword_search").val();
		if (def_val == this_val)
			$(this).val("");
	});
	$("#keyword_search").blur(function() {
		var this_val = $("#keyword_search").val();
		if (this_val == "")
			$(this).val(def_val);
	});
	
	$("#login").hover(function(){
		$(this).css({"background":"white","color":"black","border-top":"2px orange solid","border-bottom":"1px white solid"});
		$("#login_form").show();
	},function(){
		$(this).css({"color":"white","margin-left":"20px","padding":"13px","cursor":"default","background":"none","border-top":"none","border-bottom":"none"});
		$("#login_form").hide();
	});
	$("#login_form").hover(function(){
		$("#login").css({"background":"white","color":"black","border-top":"2px orange solid","border-bottom":"1px white solid"});
		$(this).show();
	},function(){
		$("#login").css({"color":"white","margin-left":"20px","padding":"13px","cursor":"default","background":"none","border-top":"none","border-bottom":"none"});
		$(this).hide();
	});
	
});

//图片轮换
var t = n = 0, count;
$(document)
		.ready(
				function() {
					count = $("#banner_list a").length;
					$("#banner_list a:not(:first-child)").hide();
					$("#banner_info").html(
							$("#banner_list a:first-child").find("img").attr(
									'alt'));
					$("#banner_info").click(
							function() {
								window.open($("#banner_list a:first-child")
										.attr('href'), "_blank")
							});
					$("#banner li")
							.click(
									function() {
										var i = $(this).text() - 1;// 获取Li元素内的值，即1，2，3，4
										n = i;
										if (i >= count)
											return;
										$("#banner_info").html(
												$("#banner_list a").eq(i).find(
														"img").attr('alt'));
										$("#banner_info")
												.unbind()
												.click(
														function() {
															window
																	.open(
																			$(
																					"#banner_list a")
																					.eq(
																							i)
																					.attr(
																							'href'),
																			"_blank")
														})
										$("#banner_list a").filter(":visible")
												.fadeOut(500).parent()
												.children().eq(i).fadeIn(1000);
										document.getElementById("banner").style.background = "";
										$(this).toggleClass("on");
										$(this).siblings().removeAttr("class");
									});
					t = setInterval("showAuto()", 4000);
					$("#banner").hover(function() {
						clearInterval(t)
					}, function() {
						t = setInterval("showAuto()", 4000);
					});
});
function showAuto() {
	n = n >= (count - 1) ? 0 : ++n;
	$("#banner li").eq(n).trigger('click');
}

//导航tab点击设置
$(function() {
    $(".main_tab li:first").addClass("currentTab").siblings().addClass("normalTab");
    $(".content div:first").show();
    $(".main_tab li").click(function() {
        switchTab(this);
    });
});
    
function switchTab(obj) {
    $(obj).removeClass("normalTab").addClass("currentTab").siblings(".currentTab").removeClass("currentTab").addClass("normalTab");
    var n = $(".main_tab li").length;
    for(var i = 0;i < n;i++){
    	$(".content #tab"+i).hide();
    }
    $("#tab"+$(".main_tab li").index($(obj))).show(); 
}